home *** CD-ROM | disk | FTP | other *** search
/ BMUG Revelations / BMUG Revelations.toast / Utilities / Random / Commodore 64c / SOURCE / Printer.c < prev    next >
Text File  |  1994-02-13  |  2KB  |  78 lines

  1. /*
  2.     Commodore 64 Emulator v0.1      Earle F. Philhower III 
  3.     Copyright (C) 1993-4            (st916w9r@dunx1.ocs.drexel.edu)
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19. #include "Serial.h"
  20. #include "Printer.h"
  21. #include "FileTypes.h"
  22.  
  23. static short printerFile;
  24. static byte printerOpen;
  25.  
  26. static byte PrinterClose(int sa);
  27. static byte PrinterOpen(char *fname, int len, int sa);
  28. static byte PrinterOutput(byte chr, int sa);
  29. static byte PrinterInput(byte *store, int sa);
  30.  
  31. void PrinterInitialize(void)
  32. {
  33.     AddSerialDevice(4, PrinterInput, PrinterOutput, PrinterOpen,
  34.         PrinterClose, NULL);
  35.     printerOpen=0;
  36. }
  37.  
  38. static byte PrinterClose(int sa)
  39. {
  40.     if (printerOpen==1) FSClose(printerFile);
  41.     printerOpen=0;
  42.     return kSerialOK;
  43. }
  44.  
  45. static byte PrinterOpen(char *fname, int len, int sa)
  46. {
  47.     if (printerOpen==1) PrinterClose(sa);
  48.     
  49.     FSDelete("\pPRINTER",0);
  50.     Create("\pPRINTER",0, APPLTYPE, PRINTERFTYPE);
  51.     FSOpen("\pPRINTER",0, &printerFile);
  52.     printerOpen=1;
  53.     return kSerialOK;
  54. }
  55.  
  56. static byte PrinterOutput(byte chr, int sa)
  57. {
  58.     long len;
  59.     char temp;
  60.  
  61.     if (printerOpen==1) {
  62.         temp=chr;
  63.         len=1;
  64.         FSWrite(printerFile, &len, &temp);
  65.         return kSerialOK; }
  66.     return kSerialError;
  67. }
  68.  
  69. static byte PrinterInput(byte *store, int sa)
  70. {
  71.     return kSerialError;
  72. }
  73.  
  74. void PrinterNewFile(void) {}
  75. void PrinterAppendFile(void) {}
  76. void PrinterXvertCharacters(void) {}
  77. void PrinterDisplayFile(void) {}
  78.